cmake_minimum_required(VERSION 3.18.1)
PROJECT(practice VERSION 0.1.0)
add_definitions(-DDEFINE_CONDITION)
set(CMAKE_BUILD_TYPE "Debug")
# OpenGL配置
find_package(OpenGL REQUIRED)

# 资源文件处理
file(GLOB ASSETS "./assets")
file(COPY ${ASSETS} DESTINATION ${CMAKE_BINARY_DIR})

# GLAD配置
add_library(glad glad/src/glad.c)
target_include_directories(glad PUBLIC glad/include)

# 新增的app库配置
file(GLOB_RECURSE APP ./glframework/*.cpp) 
add_library(app ${APP})
# 关键修复：为app库添加glad依赖
target_link_libraries(app PRIVATE glad)  # 确保头文件可见性
target_include_directories(app PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/glad/include  # 显式包含路径
)

# FFmpeg配置
include_directories(./third_party/ffmpeg/include)
set(LIB_DIR "./third_party/ffmpeg/lib")
file(GLOB_RECURSE ffmpeg "${LIB_DIR}/\*.so")

# 线程池配置
include_directories(./third_party/threadpool/include)
set(LIB_DIR "./third_party/threadpool/lib")
file(GLOB_RECURSE threadpool "${LIB_DIR}/\*.so")

find_package(ALSA REQUIRED)  # 自动定位ALSA的头文件和库路径
# 主可执行文件配置
add_executable(main main.cc)
#add_executable(main opengl/main.cc)


# 关键修复：链接所有依赖库
target_link_libraries(main PRIVATE
    app         # 新增：链接app库
    glfw
    ${GL_LIBRARY}
    glad
    ${ffmpeg}
    ${threadpool}
    ${ALSA_LIBRARIES}
    dl          # 直接链接dl库
)